<div class="layuimini-container layuimini-page-anim" style="height: 92%;">
  <div class="layuimini-main" style="height: 92%;">
    <div class="layui-btn-container">
      <button class="layui-btn layui-btn-sm" id="btn-save">保存文件</button>
    </div>
    <div class="container wrapper" style="height: 80vh;">
      <textarea id="code" name="code"></textarea>
    </div>
  </div>
</div>

<script type="text/javascript">
  $(document).ready(function () {
    var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
      lineNumbers: true,
      lineWrapping: false,
      styleActiveLine: true,
      matchBrackets: true,
      mode: "shell",
      theme: "dracula",
      keyMap: "sublime",
    });
    $.get('./api/config/crontab', function (data) {
      editor.setValue(data);
    });
    $("#btn-save").click(function () {
      var confContent = editor.getValue();
      $.post('./api/save', { content: confContent, name: "crontab.list" }, function (data) {
          layer.msg('定时任务已同步更新');
      });
    });
  });
  layui.use(["layer"], function () {
    var $ = layui.jquery,
      layer = layui.layer;
  });
</script>
